package com.yyx.jupiter.service.ablation;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yyx.jupiter.conf.PropertyConfig;
import com.yyx.jupiter.utils.AblationUtils;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;

@Service
public class AblationService {
    @Resource
    PropertyConfig propertyConfig;

    public String getStrategy(String scene, String ablationKey) throws Exception {
        String hashKey = scene + "_" + ablationKey;
        JSONObject abtest = propertyConfig.getGlobe().getJSONObject(scene);
        return AblationUtils.getStrategy(hashKey, 10000, abtest);
    }

    public Integer getBucketNumber(String scene, String ablationKey, Integer hashSize) {
        String hashKey = scene + "_" + ablationKey;
        return AblationUtils.getBucketNumber(hashKey, hashSize);
    }
}
